from lxml import etree

if __name__ == '__main__':
    root = etree.Element("root")

    child1 = etree.Element("child1")
    child1.set("class", "a")
    child1.text = "a"

    child2 = etree.Element("child2")
    child2.set("class", "b")
    child2.text = "b"

    child3 = etree.Element("child3")
    child3.set("class", "c")
    child3.text = "c"

    root.append(child1)
    root.append(child2)
    root.append(child3)

    print(etree.tounicode(root, pretty_print=True))
